home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1180 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.9 KB

  1. Path: gate.net!not-for-mail
  2. From: feathers@gate.net (Michael Feathers)
  3. Newsgroups: comp.lang.eiffel,comp.lang.ada,comp.edu,comp.lang.c,comp.lang.c++,comp.lang.modula2,comp.lang.modula3
  4. Subject: Re: Hungarian notation
  5. Followup-To: comp.lang.eiffel,comp.lang.ada,comp.edu,comp.lang.c,comp.lang.c++,comp.lang.modula2,comp.lang.modula3
  6. Date: 9 Jan 1996 07:56:58 -0500
  7. Organization: CyberGate, Inc.
  8. Message-ID: <4ctomq$1pi8@hopi.gate.net>
  9. References: <30C40F77.53B5@swsbbs.com> <30EF0415.6FE1@tus.ssi1.com> <1996Jan7.045815.8676@ohstpy> <4cpb00$nqk@news.xmission.com> <4crm6i$24mi@navajo.gate.net> <4csi2t$gsa@news.xmission.com>
  10. NNTP-Posting-Host: hopi.gate.net
  11. X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
  12.  
  13. Todd Knarr (tknarr@xmission.com) wrote:
  14. : In <4crm6i$24mi@navajo.gate.net>, feathers@gate.net (Michael Feathers) writes:
  15. : >I've never seen a variable that can be any of 9 different types in C++.
  16. : >All variables have a type.  Period.  A type can be a union or a base 
  17. : >class, but all variables have one and only one type in C++.  If you don't
  18. : >believe me, check the ARM.
  19. : You haven't worked with polymorphic classes as reference arguments or
  20. : pointers much, then. I have the following class heirarchy:
  21.  
  22. Yeah, I have.
  23.  
  24. In your example (deleted for space) you mention that a
  25. reference can stand in place for objects of any of its derived types.
  26.  
  27. I said that all variables have one-and-only-one-type.  The reference
  28. itself is a variable (as pointers are) and it has a type.
  29.  
  30. This may seem like a quibbling point, but in OOP it should be a natural
  31. assumption (because of polymorphism) that all objects of derived
  32. classes should perform in a manner appropriate to their class in
  33. the context of their base classes interfaces.  This is information
  34. hiding, in much the same way as function names hide implementation 
  35. yet provide semantic information.  If this is not the case, then the 
  36. inheritance should be suspect.
  37.  
  38. : Give me an HN prefix that tells me that, in the following prototype
  39. : Stall *HardwareChangeSignalled( Stall& ExistingStall, int ByteCount,
  40. :                                 unsigned char *aHardwareData );
  41. : the ExistingStall argument is one of the 9 subclasses and never a Stall,
  42. : and the returned pointer is one of the 9 subclasses and never a pointer to
  43. : Stall.
  44.  
  45. Why never a Stall?  If Stall's interface is present in any of its derived
  46. classes, Stall calls should be resolved.
  47.  
  48. : Without such a prefix, you can readily get the obnoxious situation of a new
  49. : programmer depending on the prefix and not realizing that he is dealing with
  50. : a polymorphic type. This can cause him problems if he refers to the source
  51. : code for Stall, depending on the HN prefix to be the actual type.
  52.  
  53. True enough, but I think that new OOP programmers should drill it into
  54. their heads that references==pointers as far as polymorphism goes (and
  55. in other ways too).  Polymorphism has to change the way that you understand
  56. code.  We are not in Kansas any more. 
  57.